package com.senken.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.senken.base.BaseController;
import com.senken.entity.Express;
import com.senken.service.IExpressService;

@Controller
@RequestMapping("/express")
public class ExpressController extends BaseController {

	@Autowired
	private IExpressService expressService;
	
	@RequestMapping("/add")
	@ResponseBody
	public Object addexpress(String expresswo,String sendname,String sendaddress,String receivename,String receivephone,String receiveaddress,String sendphone,String sendtime,String way){
		if(expressService.addexpress(expresswo, sendname, sendaddress, receivename, receivephone, receiveaddress, sendphone, sendtime,way)){
			return renderSuccess();
		}
		return renderError("添加失败");
	}
	
	@RequestMapping("/findexpress")
	@ResponseBody
	public List<Express> findexpress(int page,int state){
		return expressService.findExpress(page, state);
	}
	
	@RequestMapping("/counts")
	@ResponseBody
	public int counts(int state){
		return expressService.counts(0);
	}
	
	@RequestMapping("/state")
	@ResponseBody
	public Object updatestate(int id,int state){
		if(expressService.updateState(id, state)){
			return renderSuccess();
		}
		return renderError("更新失败");
	}
	
	@RequestMapping("/search")
	@ResponseBody
	public Express searchByWo(String expresswo){
		return expressService.findone(expresswo);
	}
}








